import java.util.Locale;

public class StringMainpulation {
    public static void main(String[] args) {
        String s1 =new String("Hello welcome to the GUN!");
        System.out.println("The length of the string:"+s1.length());
        //根据元素下标返回对应的元素
        System.out.println(s1.charAt(18));
        String s2 = "Its sun shine here...beautiful sky";
        String s3 = "HELLO WELCOME TO THE GUN!";
        //比较s1与s2是否相等
        System.out.println(s1.equals(s2));
        //比较s1与s2是否相等,但是忽略大小写
        System.out.println(s1.equalsIgnoreCase(s3));
        //按字典顺序比较两个字符串
        System.out.println("Length of s1:"+s1.length());
        System.out.println("Length of s2:"+s2.length());
        System.out.println(s1.compareTo(s3));
        //在字符串中第一个出现的元素下标
        System.out.println(s1.indexOf("l"));
        System.out.println(s1.indexOf("GUN"));
        System.out.println(s3.indexOf("GUN"));
        System.out.println(s1.lastIndexOf("l"));
        //替换字母
        System.out.println(s1.replace("G","s"));
        System.out.println(s1.replace("GUN","Big Data"));
        //中和两个字符串
        System.out.println(s1.concat(s2));
        //将s1替换成s2
        System.out.println(s2.trim());
        //大小写切换
        System.out.println(s1.toUpperCase());
        System.out.println(s1.toLowerCase());
        //StringBuilder
        StringBuilder sb = new StringBuilder("Hello");
        StringBuilder sb1 = new StringBuilder("Hello World!");
        System.out.println(sb.append(sb1));
        //添加内容到元素n之后
        System.out.println(sb1.insert(3,"NiHao"));
        //删除字符串n-m之间的元素
        System.out.println(sb1.delete(2,3));
        //字符串倒序输出
        System.out.println(sb.reverse());


    }
}
